<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RGBToHSB</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        const RGBToHSB = (r, g, b) => {
            r /= 255;
            g /= 255;
            b /= 255;
            const v = Math.max(r, g, b);
            const n = v - Math.min(r, g, b);
            const h =
                n && v === r ? (g - b) / n : v === g ? 2 + (b - r) / n : 4 + (r - g) / n;
            // h,s = n / v,b = v
            return [60 * (h < 0 ? h + 6 : h), v && (n / v) * 100, v * 100];
        };
        console.log(`RGBToHSB(252, 111, 48)的结果是:`, RGBToHSB(252, 111, 48));
    </script>
</body>

</html>